/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.hera.process.workflow.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import com.hera.base.domain.BaseDomain;
import com.hera.process.config.domain.Datasource;
import com.hera.process.config.domain.ParameterDetail;
import com.hera.process.config.domain.SistVariable;
import com.hera.process.external.domain.AdditionalTable;

/**
 *
 * @author cmontes
 */
@Entity
public class Process extends BaseDomain implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "Process")
    @TableGenerator(name = "Process", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_id", pkColumnValue = "PROCESS", allocationSize = 1)
    @Column(name = "ID_PROCESS")
    private Long idProcess;
    @Column(name = "TIME_AMOUNT")
    private Double timeAmount;
    /*@Column(name = "ID_TIMEUNIT")
    private Long idTimeunit;*/
    @JoinColumn(name = "ID_TIMEUNIT", referencedColumnName = "ID_PARAMETER_DETAIL")
    @ManyToOne
    private ParameterDetail timeUnit;
    /*@Column(name = "ID_STATUS")
    private Long idStatus;*/
    @JoinColumn(name = "ID_STATUS", referencedColumnName = "ID_PARAMETER_DETAIL")
    @ManyToOne
    private ParameterDetail status;
    @Column(name = "ID_TYPE")
    private Long idType;
    private String name;
    private String description;
    private Long version;
    @Column(name = "ACTIVATION_DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date activationDate;
    @Column(name = "ACTIVATION_USER")
    private Long activationUser;
        
    @Column(name ="FLAG_DELETE")
    private Boolean flagDelete;
    
    @JoinColumn(name = "ID_DATASOURCE", referencedColumnName = "ID_DATASOURCE")
    @ManyToOne
    private Datasource datasource;
    
    @Column(name ="DIAGRAM_WIDTH")
    private Integer diagramWidth;
    @Column(name ="DIAGRAM_HEIGHT")
    private Integer diagramHeight;
    
    
    @JoinColumn(name = "ID_CATEGORY", referencedColumnName = "ID_PARAMETER_DETAIL")
    @ManyToOne
    private ParameterDetail processCategory;
    @JoinColumn(name = "ID_PARENT", referencedColumnName = "ID_PROCESS")
    @ManyToOne
    private Process process;
        
    //@OneToMany(mappedBy = "process")
    @Transient
    private List<SistVariable> sistVariableList;
    //@OneToMany(mappedBy = "process")
    @Transient
    private List<ProcessInstance> processInstanceList;
    //@OneToMany(cascade = CascadeType.ALL, mappedBy = "process")
    @Transient
    private List<Swimlane> swimlaneList;
    //@OneToMany(cascade = CascadeType.ALL, mappedBy = "process")
    @Transient
    private List<ProcessSupervisor> processSupervisorList;    
    //@OneToMany(mappedBy = "process")
    @Transient
    private List<Process> processList;    
    //@OneToMany(mappedBy = "process")
    @Transient
    private List<AdditionalTable> additionalTableList;

    public Process() {
    }

    public Process(Long idProcess) {
        this.idProcess = idProcess;
    }

    public Long getIdProcess() {
        return idProcess;
    }

    public void setIdProcess(Long idProcess) {
        this.idProcess = idProcess;
    }

    public Double getTimeAmount() {
        return timeAmount;
    }

    public void setTimeAmount(Double timeAmount) {
        this.timeAmount = timeAmount;
    }
/*
    public Long getIdTimeunit() {
        return idTimeunit;
    }

    public void setIdTimeunit(Long idTimeunit) {
        this.idTimeunit = idTimeunit;
    }

    public Long getIdStatus() {
        return idStatus;
    }

    public void setIdStatus(Long idStatus) {
        this.idStatus = idStatus;
    }*/

    public Long getIdType() {
        return idType;
    }

    public ParameterDetail getTimeUnit() {
		return timeUnit;
	}

	public void setTimeUnit(ParameterDetail timeUnit) {
		this.timeUnit = timeUnit;
	}

	public ParameterDetail getStatus() {
		return status;
	}

	public void setStatus(ParameterDetail status) {
		this.status = status;
	}

	public void setIdType(Long idType) {
        this.idType = idType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Long getVersion() {
        return version;
    }

    public void setVersion(Long version) {
        this.version = version;
    }

    public Date getActivationDate() {
        return activationDate;
    }

    public void setActivationDate(Date activationDate) {
        this.activationDate = activationDate;
    }

    public Long getActivationUser() {
        return activationUser;
    }

    public void setActivationUser(Long activationUser) {
        this.activationUser = activationUser;
    }

	public Datasource getDatasource() {
		return datasource;
	}

	public void setDatasource(Datasource datasource) {
		this.datasource = datasource;
	}

	public List<SistVariable> getSistVariableList() {
        return sistVariableList;
    }

    public void setSistVariableList(List<SistVariable> sistVariableList) {
        this.sistVariableList = sistVariableList;
    }

    public List<ProcessInstance> getProcessInstanceList() {
        return processInstanceList;
    }

    public void setProcessInstanceList(List<ProcessInstance> processInstanceList) {
        this.processInstanceList = processInstanceList;
    }

    public List<Swimlane> getSwimlaneList() {
        return swimlaneList;
    }

    public void setSwimlaneList(List<Swimlane> swimlaneList) {
        this.swimlaneList = swimlaneList;
    }

    public List<ProcessSupervisor> getProcessSupervisorList() {
        return processSupervisorList;
    }

    public void setProcessSupervisorList(List<ProcessSupervisor> processSupervisorList) {
        this.processSupervisorList = processSupervisorList;
    }

    public ParameterDetail getProcessCategory() {
        return processCategory;
    }

    public void setProcessCategory(ParameterDetail processCategory) {
        this.processCategory = processCategory;
    }

    public List<Process> getProcessList() {
        return processList;
    }

    public void setProcessList(List<Process> processList) {
        this.processList = processList;
    }

    public Process getProcess() {
        return process;
    }

    public void setProcess(Process process) {
        this.process = process;
    }

    public List<AdditionalTable> getAdditionalTableList() {
        return additionalTableList;
    }

    public void setAdditionalTableList(List<AdditionalTable> additionalTableList) {
        this.additionalTableList = additionalTableList;
    }

    public Integer getDiagramWidth() {
		return diagramWidth;
	}

	public void setDiagramWidth(Integer diagramWidth) {
		this.diagramWidth = diagramWidth;
	}

	public Integer getDiagramHeight() {
		return diagramHeight;
	}

	public void setDiagramHeight(Integer diagramHeight) {
		this.diagramHeight = diagramHeight;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (idProcess != null ? idProcess.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof Process)) {
            return false;
        }
        Process other = (Process) object;
        if ((this.idProcess == null && other.idProcess != null) || (this.idProcess != null && !this.idProcess.equals(other.idProcess))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.hera.process.data.domain2.Process[ idProcess=" + idProcess + " ]";
    }

	public Boolean getFlagDelete() {
		return flagDelete;
	}

	public void setFlagDelete(Boolean flagDelete) {
		this.flagDelete = flagDelete;
	}
    
}
